package cn.lg.soar.message.feign;


import cn.lg.soar.core.annotations.ApiClient;
import cn.lg.soar.message.api.constant.ModuleConst;
import cn.lg.soar.message.api.model.WebSocketDTO;
import cn.lg.soar.message.api.service.IWebSocketApi;
import cn.lg.soar.message.feign.fallback.WebSocketApiFallbackFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author luguoxiang
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
@ConditionalOnMissingClass("cn.lg.soar.message.client.WebSocketApiClient")
@ApiClient
@FeignClient(
        name= ModuleConst.MODULE_NAME,
        path= ModuleConst.CLIENT_PATH + "/ws",
        fallbackFactory= WebSocketApiFallbackFactory.class,
        contextId = "WebSocketApiFeign"
)
public interface WebSocketApiFeign extends IWebSocketApi {

    @PostMapping("broadcast")
    @Override
    void broadcast(@RequestParam String topic, @RequestBody String message);

    @PostMapping("sendMessage")
    @Override
    void sendMessage(@RequestParam String topic, @RequestBody WebSocketDTO dto);

}
